package cn.itcast.bos.dao.system;

import cn.itcast.bos.domain.system.Permission;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface PermissionRepositor extends JpaRepository<Permission,Integer> {

    @Query(value = "SELECT p.* FROM t_user u,t_permission p INNER JOIN t_user_role ur,t_role_permission rp WHERE " +
            "u.C_ID = ur.C_USER_ID AND ur.C_ROLE_ID = rp.C_ROLE_ID AND rp.C_PERMISSION_ID = p.C_ID AND u.C_ID = ?",nativeQuery = true)
    List<Permission> findPermissionByUser(int id);
}
